
// Marginals means


use "~/Dropbox/Independent candidates Chile/01_data/clean_data/wave1.dta", clear
cd "~/Dropbox/Independent candidates Chile/02_analyses/figures"

set scheme plottig 

// basic regression

reg choice_clean  i.indep2  i.atr2 i.atr3 i.atr4, cl(key)
margins indep2, atmeans
marginsplot,  horizontal  xline(0.325, lwidth(medium) lcolor(black))  recast(scatter) xscale(range(0.25(0.05)0.5)) /// 
xlabel(0.25 0.3 0.35 0.4 0.45 0.5, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) yscale(range(-0.2(0.1)1.2))  ///
title("Whole Sample", size(medium)) ytitle("") xtitle("")   ylabel(,labsize(medium) labcolor(black))  ciopts(lwidth(medthick) recast(rcap))
graph export mm_all.png, replace


reg choice_clean  i.indep2 i.atr2 i.atr3 i.atr4 if populism2 == 0, cl(key)
margins indep2, atmeans
marginsplot,  horizontal  xline(0.325, lwidth(medium) lcolor(black))  recast(scatter) xscale(range(0.25(0.05)0.5)) /// 
xlabel(0.25 0.3 0.35 0.4 0.45 0.5, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) yscale(range(-0.2(0.1)1.2))  ///
title("Non-Anti-Elite", size(medium)) ytitle("") xtitle("")   ylabel(,labsize(medium) labcolor(black))
graph export mm_pop1.png, replace

reg choice_clean  i.indep2 i.atr2 i.atr3 i.atr4 if populism2 == 1, cl(key) 
margins indep2, atmeans
marginsplot,  horizontal  xline(0.325, lwidth(medium) lcolor(black))  recast(scatter) xscale(range(0.25(0.05)0.5)) /// 
xlabel(0.25 0.3 0.35 0.4 0.45 0.5, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) yscale(range(-0.2(0.1)1.2))  ///
title("Anti-Elite", size(medium)) ytitle("") xtitle("")   ylabel(,labsize(medium) labcolor(black))
graph export mm_pop2.png, replace


reg choice_clean i.indep2##i.populism2   i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2, cl(key)
margins  populism2 , at(indep2=(0 1)) atmeans
marginsplot,  horizontal  xline(0.325, lwidth(medium) lcolor(black))  recast(scatter) xscale(range(0.25(0.05)0.5)) /// 
xlabel(0.25 0.3 0.35 0.4 0.45 0.5, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) yscale(range(-0.2(0.1)1.2))  ///
title("Comparison", size(medium)) ytitle("") xtitle("")   ylabel(,labsize(medium) labcolor(black)) legend(col(1) ring(0) pos(2)) ///
ciopts(lwidth(medthick) recast(rcap))
graph export mm_int.png, replace


// Marginal means forced choice

reg choice_forced  i.indep2  i.atr2 i.atr3 i.atr4, cl(key)
margins indep2, atmeans
marginsplot,  horizontal  xline(0.5, lwidth(medium) lcolor(black))  recast(scatter) xscale(range(0.35(0.05)0.65)) /// 
xlabel(0.35 0.4 0.45 0.5 0.55 0.6 0.65, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) yscale(range(-0.2(0.1)1.2))  ///
title("Whole Sample", size(medium)) ytitle("") xtitle("")   ylabel(,labsize(medium) labcolor(black))  ciopts(lwidth(medthick) recast(rcap))
graph export mm_all_forced.png, replace



reg choice_forced i.indep2##i.populism2   i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2, cl(key)
margins  populism2 , at(indep2=(0 1)) atmeans
marginsplot,  horizontal  xline(0.5, lwidth(medium) lcolor(black))  recast(scatter) xscale(range(0.35(0.05)0.65)) /// 
xlabel(0.35 0.4 0.45 0.5 0.55 0.6 0.65, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) yscale(range(-0.2(0.1)1.2))  ///
title("Comparison", size(medium)) ytitle("") xtitle("")   ylabel(,labsize(medium) labcolor(black)) legend(col(1) ring(0) pos(2)) ///
ciopts(lwidth(medthick) recast(rcap))
graph export mm_int_forced.png, replace
